﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using LongQuanWeb.App_Code;

namespace LongQuanWeb.Admin
{
    public partial class MemberShow : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((this.Session["username"] == null) || (this.Session["username"].ToString() == string.Empty))
            {
                base.Response.Write("<font color=#ff0000 style='FONT-SIZE: 12px'>对不起,您没足够权限访问此页!!</font><br>");
                base.Response.Write("<a href='Login.aspx' target=_top style='FONT-SIZE: 12px'>重新登陆</a><br>");
                base.Response.End();
            }
            if (!IsPostBack)
            {
                base.Response.Write("<script>parent.window.document.getElementById( 'lbl_title').innerHTML='会员信息'; </script>");
                string id = Request.QueryString["id"].ToString().Trim();
                string strSql = "Select * From [User] Where UserCode=" + id + "";
                DataTable dt = DbHelperSQL.Query(strSql).Tables[0];
                if (dt != null)
                {
                    this.lbl_UserId.Text = dt.Rows[0]["UserID"].ToString().Trim();
                    this.lbl_UserName.Text = dt.Rows[0]["UserName"].ToString().Trim();
                    this.lbl_Sex.Text = dt.Rows[0]["Sex"].ToString().Trim();
                    this.lbl_GraduateYear.Text = dt.Rows[0]["GraduateYear"].ToString().Trim();
                    this.lbl_GraduateCollege.Text = dt.Rows[0]["GraduateCollege"].ToString().Trim();
                    this.lbl_Major.Text = dt.Rows[0]["Major"].ToString().Trim();
                    switch (dt.Rows[0]["Education"].ToString().Trim())
                    {
                        case "0":
                            this.lbl_Education.Text = "大专";
                            break;
                        case "1":
                            this.lbl_Education.Text = "本科";
                            break;
                        case "2":
                            this.lbl_Education.Text = "硕士";
                            break;
                        case "3":
                            this.lbl_Education.Text = "博士";
                            break;
                    }
                    this.lbl_RegAddress.Text = dt.Rows[0]["RegAddress"].ToString().Trim();
                    this.lbl_CurAddress.Text = dt.Rows[0]["CurAddress"].ToString().Trim();
                    this.lbl_Mobile.Text = dt.Rows[0]["Mobile"].ToString().Trim();
                    this.lbl_Tel.Text = dt.Rows[0]["Tel"].ToString().Trim();
                    this.lbl_Email.Text = dt.Rows[0]["Email"].ToString().Trim();
                    this.lbl_QQ.Text = dt.Rows[0]["QQ"].ToString().Trim();
                    this.lbl_IsEmployed.Text = dt.Rows[0]["Isemployed"].ToString().Trim() == "1" ? "已就业" : "未就业";
                    this.lbl_IsInCity.Text = dt.Rows[0]["InCity"].ToString().Trim() == "1" ? "本市" : "市外";
                    switch (dt.Rows[0]["CompanyType"].ToString().Trim())
                    {
                        case "0":
                            this.lbl_CompanyType.Text = "行政机关（公务员）";
                            break;
                        case "1":
                            this.lbl_CompanyType.Text = "事业单位";
                            break;
                        case "2":
                            this.lbl_CompanyType.Text = "企业";
                            break;
                        case "3":
                            this.lbl_CompanyType.Text = "自主创业";
                            break;
                        case "4":
                            this.lbl_CompanyType.Text = "大学生见习";
                            break;
                        case "5":
                            this.lbl_CompanyType.Text = "其他";
                            break;
                    }
                    this.lbl_CurCompanyName.Text = dt.Rows[0]["CurCompanyName"].ToString().Trim();
                    switch (dt.Rows[0]["unEmployedReason"].ToString().Trim())
                    {
                        case "0":
                            this.lbl_UnemployedReason.Text = "待业";
                            break;
                        case "1":
                            this.lbl_UnemployedReason.Text = "困难家庭高校毕业生";
                            break;
                        case "2":
                            this.lbl_UnemployedReason.Text = "就业困难高校毕业生";
                            break;
                        case "3":
                            this.lbl_UnemployedReason.Text = "其他";
                            break;
                    }
                    this.lbl_Mark.Text = dt.Rows[0]["Mark"].ToString().Trim();
                    this.lbl_Status.Text = dt.Rows[0]["Status"].ToString().Trim() == "1" ? "已审核" : "未审核";
                    if (dt.Rows[0]["Status"].ToString().Trim() == "1")
                        this.btn_save.Text = "取消审核";
                    else
                        this.btn_save.Text = "审核";
                }
            }
        }

        protected void btn_save_Click(object sender, EventArgs e)
        {
            string id = Request.QueryString["id"].ToString().Trim();
            if (this.btn_save.Text == "取消审核")//审核
            {
                string strSql = "Update [User] Set Status='0' where UserCode=" + id + "";
                if (DbHelperSQL.ExecuteSql(strSql) > 0)
                {
                    base.Response.Write("<script>alert('取消审核成功！');window.location='MemberList.aspx'</script>");
                }
                else
                    base.Response.Write("<script>alert('取消审核失败！');</script>");
            }
            else//未审核
            {
                string strSql = "Update [User] Set Status='1' where UserCode=" + id + "";
                if (DbHelperSQL.ExecuteSql(strSql) > 0)
                {
                    base.Response.Write("<script>alert('审核成功！');window.location='MemberList.aspx'</script>");
                }
                else
                    base.Response.Write("<script>alert('审核失败！');</script>");
            }
        }

        protected void btn_return_Click(object sender, EventArgs e)
        {
            Response.Redirect("MemberList.aspx");
        }
    }
}
